package cn.vshare.service.impl;

import cn.vshare.dao.BarrageDao;
import cn.vshare.entity.Barrage;
import cn.vshare.service.BarrageService;
import cn.vshare.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@Service
public class BarrageServiceImpl implements BarrageService {

    @Autowired
    private BarrageDao barrageDao;

    //增
    @Override
    public boolean addBarrage(Barrage barrage) {
        String id =UUID.randomUUID().toString();
        barrage.setCreateTime(DateUtil.getCurrDate());
        barrage.setBid(id);
       /* User user=new User();
        user.setId("0c527243-9949-4248-8f4b-ce1e9641c80a");

        barrage.setUser(user);*/
        return barrageDao.addBarrage(barrage);
    }

    //删
    @Override
    public boolean delBarrage(Barrage barrage) {
        return barrageDao.delBarrage(barrage);
    }

    //查
    @Override
    public List<Barrage> queryBarrageByVideo(String videoId) {
        List<Barrage> list = new ArrayList<Barrage>();
        list = barrageDao.queryBarrageByVideo(videoId);
        return list;
    }

    //筛选
    @Override
    public List<Barrage> queryBarrageFilterByUser(String videoId, List<String> list) {
        List<Barrage> listBarrage = new ArrayList<Barrage>();
        listBarrage = barrageDao.queryBarrageFilterByUser(videoId,list);
        return listBarrage;
    }

    public BarrageDao getBarrageDao() {
        return barrageDao;
    }

    public void setBarrageDao(BarrageDao barrageDao) {
        this.barrageDao = barrageDao;
    }
}
